package cn.vivi.seckill.service.impl;

import cn.vivi.seckill.mapper.SecKillGoodsMapper;
import cn.vivi.seckill.pojo.SeckillGoods;
import cn.vivi.seckill.service.SecKillGoodsService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SecKillGoodsServiceImpl implements SecKillGoodsService {

    @Autowired
    private SecKillGoodsMapper secKillGoodsMapper;

    @Override
    public SeckillGoods findByGoodsId(String goodsId) {
        return secKillGoodsMapper.selectOne(new QueryWrapper<SeckillGoods>().eq("goods_id", goodsId));
    }

    @Override
    public int updateById(SeckillGoods seckillGoods) {
        return secKillGoodsMapper.updateById(seckillGoods);
    }

    @Override
    public int updateStockCount(SeckillGoods seckillGoods) {
        return secKillGoodsMapper.updateStockCount(seckillGoods);
    }

    @Override
    public List<SeckillGoods> findAllSecKillGoods() {
     return secKillGoodsMapper.selectList(null);
    }

}
